#coding=utf-8
from report.models import Report
from django.contrib.contenttypes.models import ContentType


def add_report(object, user):
    content_type = ContentType.objects.get_for_model(object)
    try:
        report,created = Report.objects.get_or_create(content_type=content_type, object_pk = object.pk, user=user)
        if not created:
            report.times += 1     
            report.save()  
    except Report.MultipleObjectsReturned:
        pass
        
        